import { HttpClient, HttpParams } from '@angular/common/http';
import { Injectable } from '@angular/core';
import { Observable } from 'rxjs';
import { LICENSE_PDF, SINGLE_UPLOAD_URL } from '../api/upload';

@Injectable({
  providedIn: 'root'
})
export class UploadService {

  constructor(
    private http: HttpClient
  ) { }

  _upload(data: any, type = false): Observable<any>{
    if(type === false){
      // data.su = 'pb'
      // data.bo = 'fc'
      return this.http.post(SINGLE_UPLOAD_URL + 'New', data)
    }else{
      data.suCode = 'pb'
      data.boCode = 'fc'
      // data.su = 'pb'
      // data.bo = 'fc'
      return this.http.post('/api/gsxmcp/pb/fm/v1.0/billsUploadNew', data)
    }

    // return this.http.post('/api/gsxmcp/pb/fm/v1.0/uploadNew', data)
  }

  _getLicensePdf(cardNo: string): Observable<any>{
    const params = new HttpParams({ fromObject: { cardNo } })
    return this.http.get(LICENSE_PDF, { params })
  }
}
